 #include<stdio.h>
#include<stdlib.h>
#include"client.h"
int creatFile(Client cli[])
{
	FILE *fp;
	int n;
	if((fp=fopen("d:\\client.dat","w"))==NULL)
	{
		printf("can not open file !\n");
		exit(0);
	}
	printf("input client\'information:\n");
	n=readCli(cli,NUM);
fwrite(cli,sizeCli,n,fp);
   fclose(fp);
   return n;
}
int readFile(Client cli[])
{
	FILE *fp;
	int i=0;
	if((fp=fopen("d:\\client.dat","r"))==NULL)
	{
		printf("file does not exist,create it first:\n");
	    return 0;
	}
	 fread(&cli[i],sizeCli,1,fp);
	 while(!feof(fp))
	 {
		 i++;
		 fread(&cli[i],sizeCli,1,fp);
	 }
	 fclose(fp);
	 return i;
}
void saveFile(Client cli[],int n)
{
	FILE *fp;
	if((fp=fopen("d:\\client.dat","w"))==NULL)
	{
		printf("can not open file !\n");
	    exit(0);
	}
	fwrite(cli,sizeCli,n,fp);
	fclose(fp);
}


